package com.w.usercenter.exception;

import com.w.usercenter.common.ErrorCode;
import lombok.Getter;

/**
 * 业务异常类
 *
 * @author wzp
 * @since 2024/8/10
 */
@Getter
public class BusinessException extends RuntimeException {

    private static final long serialVersionUID = 6950696111538339715L;

    private final int code;

    private final String description;

    public BusinessException(int code, String message, String description) {
        super(message);
        this.code = code;
        this.description = description;
    }

    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMsg());
        this.code = errorCode.getCode();
        this.description = errorCode.getDescribe();
    }

    public BusinessException(ErrorCode errorCode, String description) {
        super(errorCode.getMsg());
        this.code = errorCode.getCode();
        this.description = description;
    }
}
